<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <script>
    let templatestr = 'I wanna sing {{song}}, {{mood}}'

    let data = {
      song: 'dangerous',
      mood: 'delightedly'
    }
    
    function render(str, data) {
      return str.replace(/\{\{(\w+)\}\}/g, (find, $1) => data[$1])
    }

    console.log(render(templatestr, data))
  </script>
</body>
</html>